package com.atguigu.springcloud.service;

import java.util.List;

import org.springframework.stereotype.Component;

import com.atguigu.springcloud.entity.Dept;

import feign.hystrix.FallbackFactory;

@Component //千万不能丢
public class DeptClientServiceFallbackFactory implements FallbackFactory<DeptClientService> {

	@Override
	public DeptClientService create(Throwable cause) {
		return new DeptClientService() {

			@Override
			public Dept get(long id) {
				return new Dept().setDeptno(id)
						.setDname("该ID:" + id + "没有对应的信息,Consumer提供的降级信息,此刻Provider服务已经关闭")
						.setDb_source("no this database in MySQL");
			}

			@Override
			public List<Dept> list() {
				return null;
			}

			@Override
			public boolean add(Dept dept) {
				return false;
			}
			
		};
	}

}
